#include<stdio.h>
int main()
{
	int i,j,n;
	double x,y;
	char ch;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c %lf",&ch,&x);
		if(ch=='M')
		y=x/1.09;
		if(ch=='F')
		y=x*1.09;		
		printf("%.2lf\n",y);
	}
	return 0;
 } 
